// 引入路由组件
import Home from '@/views/Home'
import Search from '@/views/Search'
import Login from '@/views/Login'
import Register from '@/views/Register'
import Detail from '@/views/Detail'
import AddCartSuccess from '@/views/AddCartSuccess'
import ShopCar from '@/views/ShopCart'

export default  [
  // 购物车
  {
    path:'/shopcar',
    component:ShopCar,
    meta:{show:true} // 路由元信息 
  },
  // 添加到购物车成功
  {
    path:'/addcartsuccess',
    name:'addcartsuccess',
    component:AddCartSuccess,
    meta: { show: true }
  },
  {
    path:'/detail/:skuid',
    component:Detail,
    meta: { show: true }
  },
  {
    path: '/home',
    component: Home,
    meta: { show: true }
  },
  {
    path: '/search/:keyword?',
    component: Search,
    meta: { show: true },
    name: 'search',
    // props:true
    // 对象写法
    // props:{a:1,b:2}
    // 函数写法
    // props:($route) =>{
    //   return {keyword:$route.params.keyword}
    // }
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/register',
    component: Register,
    meta: { show: false }
  },

  // 重定向,项目启动时
  {
    path: '*',
    redirect: '/home'
  }
]